package com.rf.richfitwheel.workflow.entity;

import com.rf.richfitwheel.workflow.conf.WorkflowContants;
import lombok.Data;
import org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity;

import java.util.Date;
import java.util.Map;

@Data
public class HistoryProcessVo {

    public HistoryProcessVo(HistoricProcessInstanceEntity hpi) {
//        System.out.println(hpi.getProcessVariables());
        this.setId(hpi.getProcessInstanceId());
        this.setKey(hpi.getProcessDefinitionKey());
        this.setProcessName(hpi.getProcessDefinitionName());
        this.setStartTime(hpi.getStartTime());
        this.setEndTime(hpi.getEndTime());
        this.setProcessState(hpi.getEndTime() == null ? WorkflowContants.ProcessInstanceState.RUN.getValue() : WorkflowContants.ProcessInstanceState.END.getValue());
        if (hpi.getDeleteReason() != null) {
            this.setProcessState(WorkflowContants.ProcessInstanceState.TERMINATED.getValue());
        }
        this.setStartUserId(hpi.getStartUserId());
        this.deleteReason = hpi.getDeleteReason();
        this.processDifinationId = hpi.getProcessDefinitionId();
    }

    private String id;
    private String processName;
    private String key;
    private Date startTime;
    private Date endTime;
    private String processState;
    private String startUserId;
    private String startUserName;
    private String deleteReason;
    private String description;
    private String processDifinationId;
    private String processId;
    private Map<String, Object> processVariables;
}
